package Sevlet;

import bean.person;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class manage extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        person p = (person) req.getSession().getAttribute("person");
        if (p!=null){   //已登录
            if (p.getUserName().indexOf("staff")==0){       // 员工
                resp.sendRedirect("http://localhost:8080/staff/info.jsp");
            }else {
                if (p.getUserName().equals("root")){        //root管理员
                    resp.sendRedirect("http://localhost:8080/root/updateStaff.jsp");
                }else {                                     //游客
                    resp.sendRedirect("http://localhost:8080/tourist/info.jsp");
                }
            }
        }else {         //未登录()
            resp.sendRedirect("login.jsp?jmpFlag=3");
        }
    }
}
